#include<stdio.h>
int main()
{	int x[100],n,i,j,count;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&x[i]);
	count=0;
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(x[i]-x[j]==1||x[j]-x[i]==1)
				count++;
	printf("%d\n",count);
}
